package com.lsz.deport.ui.order;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.request.RequestOptions;
import com.lsz.deport.R;
import com.lsz.deport.TemporaryDataUtil;
import com.lsz.deport.db.bean.CommodityBean;
import com.lsz.deport.db.bean.PackageBean;
import com.lsz.deport.db.dao_utils.DaoUtils;
import com.lsz.deport.json.OrderDetailBean;
import com.lsz.deport.viewutil.BigDecimalUtils;
import com.lsz.deport.viewutil.SpannableUtil;
import com.util_code.dagger.help.GlideApp;
import com.util_code.widget.recycleadpter.BaseRecycleViewAdapter;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class OrderAdapter extends BaseRecycleViewAdapter<OrderDetailBean> {

    public OrderAdapter(Context context) {
        super(context);
    }

    @Override
    protected void onBindBaseViewHolder(RecyclerView.ViewHolder holder, OrderDetailBean item) {
        if (holder instanceof OrderHolder) {
            OrderHolder orderHolder = (OrderHolder) holder;
            Drawable drawable = mContext.getResources().getDrawable(R.drawable.bg_menu_food);
            RequestOptions options = new RequestOptions();
            options = options.placeholder(drawable);
            GlideApp.with(mContext).load(item.imgIcon).apply(options).dontAnimate().into(orderHolder.ivCommodityImage);
            orderHolder.tvCommodityName.setText(item.name);
//            orderHolder.tvCommodityBox.setText("");
            orderHolder.tvCommodityNumber.setText("x " + item.count);
        }
    }

    @Override
    protected RecyclerView.ViewHolder onCreateBaseViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_order_view, parent, false);
        return new OrderHolder(view);
    }

    @Override
    protected int getBaseItemViewType(int position) {
        return 0;
    }

    class OrderHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.iv_commodity_image)
        ImageView ivCommodityImage;
        @BindView(R.id.tv_commodity_name)
        TextView tvCommodityName;
        @BindView(R.id.tv_commodity_box)
        TextView tvCommodityBox;
        @BindView(R.id.tv_commodity_number)
        TextView tvCommodityNumber;

        OrderHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }

}
